package top.javai.www;

import org.mybatis.spring.annotation.MapperScan;
import org.quartz.Scheduler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
import top.javai.www.quartz.MyJobFactory;


@MapperScan("top.javai.www.dao")
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
@Configuration
public class SpringBootApplicationClass {
    public static void main(String[] args) {
        SpringApplication.run(SpringBootApplicationClass.class,args);
    }

    @Autowired
    private MyJobFactory myJobFactory;

    @Bean
    public SchedulerFactoryBean schedulerFactoryBean(){
        SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean();
        schedulerFactoryBean.setJobFactory(myJobFactory);
        System.out.println("myJobFactory"+myJobFactory);
        return schedulerFactoryBean;
    }
    @Bean
    public Scheduler scheduler(){
        Scheduler scheduler = schedulerFactoryBean().getScheduler();
        return scheduler;
    }

}
